<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Xoqal.Presentation.Controls" xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:resources="clr-namespace:Xoqal.Resources;assembly=Xoqal.Resources"
                    xmlns:wt="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit">

    <Style TargetType="{x:Type local:Pager}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Pager}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="4" DataContext="{TemplateBinding PagerController}">
                            <StackPanel.Resources>
                                <Style TargetType="{x:Type Button}">
                                    <Setter Property="FontFamily" Value="Webdings" />
                                    <Setter Property="Padding" Value="4,0" />
                                    <Setter Property="Margin" Value="2,0,2,0" />
                                </Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Margin" Value="2,0,2,0" />
                                    <Setter Property="FontSize" Value="12" />
                                    <Setter Property="VerticalAlignment" Value="Center" />
                                </Style>
                                <Style TargetType="{x:Type local:NumericTextBox}">
                                    <Setter Property="Margin" Value="2,0,2,0" />
                                    <Setter Property="VerticalAlignment" Value="Center" />
                                    <Setter Property="FontSize" Value="12" />
                                </Style>
                                <Style TargetType="{x:Type ComboBox}">
                                    <Setter Property="FontSize" Value="12" />
                                </Style>
                            </StackPanel.Resources>
                            <Button Command="{Binding Path=GotoFirstPageCommand}">
                                <Image Source="/Xoqal.Presentation;component/Assets/Images/First.png" Width="16" Height="16"
                                       FlowDirection="{Binding FlowDirection, RelativeSource={RelativeSource AncestorType={x:Type local:Pager}}}"/>
                            </Button>
                            <Button Command="{Binding Path=GotoPreviousPageCommand}">
                                <Image Source="/Xoqal.Presentation;component/Assets/Images/Previous.png" Width="16" Height="16"
                                       FlowDirection="{Binding FlowDirection, RelativeSource={RelativeSource AncestorType={x:Type local:Pager}}}"/>
                            </Button>

                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="4,0">
                                <TextBlock Text="{x:Static resources:Resource.Page}" />
                                <local:NumericTextBox Text="{Binding Path=CurrentPage, ValidatesOnExceptions=True}" />
                                <TextBlock Text="{Binding Path=PageCount, StringFormat={x:Static resources:Resource.OfPage}}" />
                            </StackPanel>

                            <Button Command="{Binding Path=GotoNextPageCommand}">
                                <Image Source="/Xoqal.Presentation;component/Assets/Images/Next.png" Width="16" Height="16"
                                       FlowDirection="{Binding FlowDirection, RelativeSource={RelativeSource AncestorType={x:Type local:Pager}}}"/>
                            </Button>
                            <Button Command="{Binding Path=GotoLastPageCommand}">
                                <Image Source="/Xoqal.Presentation;component/Assets/Images/Last.png" Width="16" Height="16" 
                                       FlowDirection="{Binding FlowDirection, RelativeSource={RelativeSource AncestorType={x:Type local:Pager}}}"/>
                            </Button>
                            <Line X1="0" Y1="0" X2="0" Y2="14" Stroke="Gray" StrokeThickness="1" Margin="5" />
                            <ComboBox SelectedValue="{Binding PageSize}" 
                                      FlowDirection="{Binding FlowDirection, RelativeSource={RelativeSource AncestorType={x:Type local:Pager}}}">
                                <ComboBox.ItemsSource>
                                    <x:Array Type="{x:Type sys:Int32}">
                                        <sys:Int32>10</sys:Int32>
                                        <sys:Int32>20</sys:Int32>
                                        <sys:Int32>50</sys:Int32>
                                        <sys:Int32>100</sys:Int32>
                                    </x:Array>
                                </ComboBox.ItemsSource>
                            </ComboBox>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:EnumCheckBoxList}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EnumCheckBoxList}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
                        <ListBox ItemsSource="{TemplateBinding EnumItems}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="{Binding IsSelected}" Content="{Binding Text}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:MultiSelectorListBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MultiSelectorListBox}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>               
                            </Grid.RowDefinitions>
                            <CheckBox IsChecked="{Binding IsAllChecked, RelativeSource={RelativeSource AncestorType={x:Type local:MultiSelectorListBox}}}"
                                      Margin="8,5"/>
                            <ListBox Grid.Row="1" ItemsSource="{TemplateBinding ItemsSource}" VerticalAlignment="Stretch">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding IsSelected}" Margin="2">
                                            <ContentPresenter Content="{Binding Data}" />
                                        </CheckBox>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Grid>
                        
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:EnumRadioList}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="SelectedValuePath" Value="Value" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Background="Transparent" Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ListBoxItem Tag="{Binding Value}" Content="{Binding Text}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <Border BorderThickness="0" Background="Transparent">
                                    <RadioButton Focusable="False" IsHitTestVisible="False" IsChecked="{TemplateBinding IsSelected}">
                                        <ContentPresenter />
                                    </RadioButton>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border BorderThickness="0" Padding="0" BorderBrush="Transparent" Background="Transparent"
                  SnapsToDevicePixels="True">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type local:TimePicker}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TimePicker}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid DataContext="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}" FlowDirection="LeftToRight">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <TextBox FlowDirection="RightToLeft" x:Name="PART_HourTextBox" Grid.Column="0" Text="{Binding Hour, UpdateSourceTrigger=PropertyChanged}" MaxLength="2"/>
                            <TextBlock Grid.Column="1" Text=":" Margin="2,0"/>
                            <TextBox FlowDirection="RightToLeft" x:Name="PART_MinuteTextBox" Grid.Column="2" Text="{Binding Minute, UpdateSourceTrigger=PropertyChanged}" MaxLength="2"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:DateTimePicker}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DateTimePicker}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid DataContext="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="2*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <wt:DatePicker SelectedDate="{Binding DatePart, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            <local:TimePicker Margin="2,0,0,0" Grid.Column="1" TimeValue="{Binding TimePart, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsDefaultNow="False"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>